package com.sky.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sky.entity.Oauth2ThirdAccount;
import com.sky.entity.SysUser;
import com.sky.mapper.SysUserMapper;
import com.sky.service.SysUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @projectName: netty-cloud
 * @package: com.sky.service.impl
 * @className: SysUserServiceImpl
 * @author: zhl
 * @description: TODO
 * @date: 2024/4/24 14:18
 * @version: 1.0
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    @Resource
    private SysUserMapper sysUserMapper;

    /**
     * @param thirdAccount :
     * @return Integer
     * @author zhl
     * @description 根据第三方数据生成用户信息
     * @date 2024/4/29 15:30
     */
    @Override
    public Integer saveByThirdAccount(Oauth2ThirdAccount thirdAccount) {
        SysUser sysUser = new SysUser();
        sysUser.setUserName(thirdAccount.getName());
        // 头像
        String avatarUrl = thirdAccount.getAvatarUrl();
        // 数据来源（第三方表示：gitee、github等）
        String accountType = thirdAccount.getType();
        return sysUserMapper.insert(sysUser);
    }
}
